<!--
 * @Author: 李天惊 uf_lee@163.com
 * @Date: 2022-12-20 14:35:28
 * @LastEditors: 李小晴 2689279066@qq.com
 * @LastEditTime: 2023-07-19 20:39:04
 * @FilePath: \grazlink20\uc_sys\src\views\Asset\Pasture\components\Edit.vue
 * Copyright (c) 2023 by 李天惊 uf_lee@163.com, All Rights Reserved. 
-->
<script setup lang="ts">
import { ref, reactive, PropType } from 'vue'
import { ContentWrap } from '@/components/ContentWrap'
import { Descriptions } from '@/components/Descriptions'

import { spFeedPlanSeeApi } from '@/api/sp/feed'
import { Table } from '@/components/Table'
const data = ref<any>({})

const props = defineProps({
  detailSchema: {
    type: Array as PropType<DescriptionsSchema[]>,
    default: () => []
  },
  id: {
    type: String,
    default: null
  }
})
// 调用查看接口获取信息
const getSee = async () => {
  const res = await spFeedPlanSeeApi({ id: props.id })
    .catch(() => {})
    .finally(() => {})
  if (res) {
    data.value = res.data
  }
}

const feed_columns = reactive<TableColumn[]>([
  {
    field: 'index',
    label: '序号',
    type: 'index',
    width: 30
  },
  {
    field: 'enclosure_name',
    label: '栏位',
    width: 150
  },
  {
    field: 'enclosure_num',
    label: '存栏数'
  },
  {
    field: 'forage_formula_name',
    label: '饲料配方',
    width: 150
  },
  {
    field: 'threshold',
    label: '喂养阈值',
    width: 85
  },
  {
    field: 'feed_time',
    label: '喂养时间',
    width: 180
  },
  {
    field: 'note',
    label: '备注'
  }
])

const init = async () => {
  await getSee()
}
init()
</script>

<template>
  <ContentWrap title="主数据">
    <Descriptions :schema="props.detailSchema" :data="data" />
  </ContentWrap>
  <ContentWrap title="明细">
    <Table :columns="feed_columns" :data="data.detailed" :selection="false" :border="true" />
  </ContentWrap>
</template>
